import {request} from '/@/utils/service';
import {UserPageQuery, AddReq, DelReq, EditReq, InfoReq} from '@fast-crud/fast-crud';
import {controlJournalStore} from "/@/stores/modules/controljournal";

export const apiPrefix = '/api/system/area/';

export function GetList(query: UserPageQuery) {
    return request({
        url: 'api/spider/info/agent',
        method: 'get',
        params: query,
    });
}

export function GetObj(id: InfoReq) {
    return request({
        url: apiPrefix + id,
        method: 'get',
    });
}

export function AddObj(obj: AddReq) {
    return request({
        url: '/api/spider/agent/upload',
        method: 'post',
        data: obj,
    });
}

export function UpdateObj(obj: EditReq) {
    return request({
        url: apiPrefix + obj.id + '/',
        method: 'put',
        data: obj,
    });
}

export function DelObj(id: DelReq) {
    return request({
        url: apiPrefix + id + '/',
        method: 'delete',
        data: {id},
    });
}

export function SwitchControl(id: BigInt, action: String) {
    return request({
        url: '/api/spider/agent/control',
        method: 'get',
        params: {
            id,
            action
        },
    });
}

export function StartAll(){
    return request({
        url: '/api/spider/agent/control',
        method: 'get',
    });
}

export function closeAll(){
    return request({
        url: '/api/spider/agent/closeAll',
        method: 'get',
    })
}

export function ChangeAll(id: BigInt, action: String,end_id: BigInt){
    return request({
        url: '/api/spider/agent/control',
        method: 'get',
        params: {
            id,
            action,
            end_id
        },
    });
}
